package com.epoint.androidphone.mobileoa.service.mqtt;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import com.epoint.androidmobile.bizlogic.dbservice.DBFrameUtil;
import com.epoint.androidmobile.bizlogic.mail.task.Mail_GetList_Task;
import com.epoint.androidphone.R;
import com.epoint.androidphone.mobileoa.service.receiver.MessageReceiver;
import com.epoint.androidphone.mobileoa.ui.mail.MailBoxListView;
import com.ibm.mqtt.MqttAdvancedCallback;
import com.ibm.mqtt.MqttClient;

/**
 * @author liyc
 * @time 2013-8-13 下午4:48:26
 * @annotation 
 */
public class MQTTV2Util {
	MqttClient mqttClient;

	public void MQTT_Connnect(final Context con)
	{
		try{
			mqttClient = new MqttClient(con.getString(R.string.message_push_server_ip));
			mqttClient.registerAdvancedHandler(new EpointMQTTCallback(con));
			String userguid = new DBFrameUtil(con).getUserGuid();
			String topicMail = "NewMail/"+userguid;
			String topicTodo = "NewTodo/"+userguid;
			mqttClient.connect(com.ibm.micro.client.mqttv3.MqttClient.generateClientId(), true, (short) 30);
			mqttClient.subscribe(new String[]{topicMail,topicTodo}, new int[]{0,0});
		}catch(Exception e)
		{
			e.printStackTrace();
		}
	}
}
